<?php
/**
 * 外网访问链接
 * 
 * @version $Id: Url.php 269 2012-04-14 09:55:06Z linsir123 $
 */
class controllerUrl extends AppController 
{
	/**
	 * 淘宝页页面跳转
	 */
	public function actionPage()
	{
		$data = trim($_GET['data']);
		$action = trim($_GET['action']);
		if (empty($action) || empty($data)) 
			return ;
			
		///
		$url = '';
		switch ($action) {
			case 'channel':
				$list = App::O('_nav.header');
				$url = isset($list[$data]) ? $list[$data][1] : '';
				break;
		}
		
		///
		$this->_reload($url);
	}
	
	/**
	 * 淘宝图片跳转
	 */
	public function actionPhoto()
	{
		$data = trim($_GET['data']);
		$action = trim($_GET['action']);
		if (empty($action) || empty($data)) 
			return ;
			
		///
		$url = '';
		$data = base64_decode($data);
		switch ($action) {
			case 'item':
				$data = explode('@@', $data);
				if (is_array($data) && count($data) == 2) 
					$url = "http://{$data[0]}.taobaocdn.com/bao/uploaded/{$data[1]}";
					
				break;
				
			case 'shop':
				$url = 'http://logo.taobaocdn.com/shop-logo'.$data;
				break;
		}
		
		///
		$this->_reload($url);
	}
	
	
	/// 以下为私有方法 ///
	
	
	/**
	 * 页面跳转
	 */
	private function _reload($url)
	{
		if (!empty($url)) 
			header('Location:'.$url);
			
		///
		exit();
	}
}
